package com.example.administrator.yuejian35.Find.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.yuejian35.Config;
import com.example.administrator.yuejian35.Find.activity.PostActivity;
import com.example.administrator.yuejian35.Find.bean.Post;
import com.example.administrator.yuejian35.Find.bean.PostPic;
import com.example.administrator.yuejian35.R;
import com.example.administrator.yuejian35.RoundTransform;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static com.example.administrator.yuejian35.Config.MasterImages_URL;
import static com.example.administrator.yuejian35.Config.PostImages_URL;

/**
 * Created by HP on 2017/9/26.
 */

public class PostPicAdapter extends RecyclerView.Adapter<PostPicAdapter.ViewHolder> {
    private Context context;
    private List<PostPic> piclist=new ArrayList<>();
    private List<Integer> heightList;


    public PostPicAdapter(Context c, List<PostPic> piclist){
        this.context = c;
        this.piclist = piclist;

    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_pic, parent, false);
        ViewHolder vh = new ViewHolder(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        PostPic postPic = piclist.get(position);
        Picasso.with(context)
                .load(Config.PostImages_URL+postPic.getPic())
                .into(holder.pic);

    }

    @Override
    public int getItemCount() {
        return piclist.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public ImageView pic;

        public ViewHolder(View view) {
            super(view);
            pic = (ImageView) view.findViewById(R.id.post_postpic);
        }
    }
}

